/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itschapala.dsw2.EventosA.modelo;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author User
 */
@Entity
@Table(name = "register")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Register.findAll", query = "SELECT r FROM Register r"),
    @NamedQuery(name = "Register.findByIdRegister", query = "SELECT r FROM Register r WHERE r.idRegister = :idRegister"),
    @NamedQuery(name = "Register.findByNameUser", query = "SELECT r FROM Register r WHERE r.nameUser = :nameUser"),
    @NamedQuery(name = "Register.findByFirstName", query = "SELECT r FROM Register r WHERE r.firstName = :firstName"),
    @NamedQuery(name = "Register.findByLastName", query = "SELECT r FROM Register r WHERE r.lastName = :lastName"),
    @NamedQuery(name = "Register.findByPassword", query = "SELECT r FROM Register r WHERE r.password = :password"),
    @NamedQuery(name = "Register.findByEmail", query = "SELECT r FROM Register r WHERE r.email = :email")})
public class Register implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idRegister")
    private Integer idRegister;
    @Size(max = 45)
    @Column(name = "Name User")
    private String nameUser;
    @Size(max = 45)
    @Column(name = "FirstName")
    private String firstName;
    @Size(max = 45)
    @Column(name = "LastName")
    private String lastName;
    @Column(name = "Password")
    private Integer password;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 45)
    @Column(name = "Email")
    private String email;
    @JoinColumn(name = "idRegister", referencedColumnName = "idLogin", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Login login;
    @JoinColumn(name = "idRegister", referencedColumnName = "idtable1", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Information information;

    public Register() {
    }

    public Register(Integer idRegister) {
        this.idRegister = idRegister;
    }

    public Integer getIdRegister() {
        return idRegister;
    }

    public void setIdRegister(Integer idRegister) {
        this.idRegister = idRegister;
    }

    public String getNameUser() {
        return nameUser;
    }

    public void setNameUser(String nameUser) {
        this.nameUser = nameUser;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public Integer getPassword() {
        return password;
    }

    public void setPassword(Integer password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Login getLogin() {
        return login;
    }

    public void setLogin(Login login) {
        this.login = login;
    }

    public Information getInformation() {
        return information;
    }

    public void setInformation(Information information) {
        this.information = information;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idRegister != null ? idRegister.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Register)) {
            return false;
        }
        Register other = (Register) object;
        if ((this.idRegister == null && other.idRegister != null) || (this.idRegister != null && !this.idRegister.equals(other.idRegister))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "mx.itschapala.dsw2.EventosA.modelo.Register[ idRegister=" + idRegister + " ]";
    }
    
}
